Public Class ProfitabilityReport_Print
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents litReport As System.Web.UI.WebControls.Literal
    Protected WithEvents litReportForCN As System.Web.UI.WebControls.Literal
    Protected WithEvents lblGrandTotalCost As System.Web.UI.WebControls.Label
    Protected WithEvents lblGrandTotalValue As System.Web.UI.WebControls.Label
    Protected WithEvents lblGrandTotalMargin As System.Web.UI.WebControls.Label
    Protected WithEvents lblGrandTotalMarginPercent As System.Web.UI.WebControls.Label

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then
            With CType(Session(ProfitabilityReport.PROFITABILITY_REPORT_SESSION_NAME), CProfitabilityReport)
                .Output = Report.EReportOutputType.Printer
                Me.litReport.Text = .GetReportHTML
                Me.litReportForCN.Text = .GetReportHTMLForCN

                Me.lblGrandTotalCost.Text = FormatNumber(.GrandTotalCost, 2)
                Me.lblGrandTotalValue.Text = FormatNumber(.GrandTotalValue, 2)

                Me.lblGrandTotalValue.ForeColor = System.Drawing.Color.DarkBlue

                ' If Value is negative, show in red
                If .GrandTotalValue < 0 Then
                    Me.lblGrandTotalValue.ForeColor = System.Drawing.Color.Red
                    Me.lblGrandTotalMargin.ForeColor = System.Drawing.Color.Red
                    Me.lblGrandTotalMarginPercent.ForeColor = System.Drawing.Color.Red
                End If

                Me.lblGrandTotalMargin.Text = FormatNumber(.GrandTotalMargin, 2)
                Try
                    Me.lblGrandTotalMarginPercent.Text = FormatNumber(.GrandTotalMarginPercent, 2)
                Catch ex As Exception
                End Try

            End With
        End If
    End Sub

End Class
